import 'package:flutter/material.dart';
import 'package:flutter_app/models/room_list_item_data.dart';
import 'package:flutter_app/widgets/commom_image.dart';
import 'package:flutter_app/widgets/tags.dart';

// const List<RoomListItemData> dataList = [
//   RoomListItemData(
//       title: '朝阳门南大街 2室1厅 8300元',
//       subTitle: "二室/114/东|北/朝阳门南大街",
//       imageUrl:
//           "https://tva1.sinaimg.cn/large/006y8mN6ly1g6wtu9t1kxj30lo0c7796.jpg",
//       price: 1200,
//       id: '11',
//       tags: ["近地铁", "集中供暖", "新上", "随时看房"]),
//   RoomListItemData(
//       title: '整租 · CBD总部公寓二期 临近国贸 精装修 随时拎包入住',
//       subTitle: "一室/110/西/CBD总部公寓二期",
//       imageUrl:
//           "https://tva1.sinaimg.cn/large/006y8mN6ly1g6wtu5s7gcj30lo0c7myq.jpg",
//       price: 6000,
//       id: '22',
//       tags: ["近地铁", "随时看房"]),
//   RoomListItemData(
//       title: '朝阳门南大街 2室1厅 8300元',
//       subTitle: "二室/114/东|北/朝阳门南大街",
//       imageUrl:
//           "https://tva1.sinaimg.cn/large/006y8mN6ly1g6wtu5s7gcj30lo0c7myq.jpg",
//       price: 1200,
//       id: '13',
//       tags: ["近地铁", "集中供暖", "新上", "随时看房"]),
//   RoomListItemData(
//       title: '整租 · CBD总部公寓二期 临近国贸 精装修 随时拎包入住',
//       subTitle: "一室/110/西/CBD总部公寓二期",
//       imageUrl:
//           "https://tva1.sinaimg.cn/large/006y8mN6ly1g6wtu9t1kxj30lo0c7796.jpg",
//       price: 6000,
//       id: '21',
//       tags: ["近地铁", "随时看房"]),
//   RoomListItemData(
//       title: '朝阳门南大街 2室1厅 8300元',
//       subTitle: "二室/114/东|北/朝阳门南大街",
//       imageUrl:
//           "https://tva1.sinaimg.cn/large/006y8mN6ly1g6wtu9t1kxj30lo0c7796.jpg",
//       price: 1200,
//       id: '14',
//       tags: ["近地铁", "集中供暖", "新上", "随时看房"]),
// ];

class HouseItem extends StatelessWidget {
  const HouseItem(
    this.data, {
    Key? key,
  }) : super(key: key);
  final RoomListItemData data;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.pushNamed(context, '/houseDetail/${data.id}');
      },
      child: Container(
        padding: const EdgeInsets.fromLTRB(10, 20, 10, 20),
        height: 170,
        child: Row(
          children: [
            CommonImage(
              src: data.imageUrl,
              width: 200,
              height: 120,
            ),
            const Padding(padding: EdgeInsets.only(right: 10)),
            Expanded(
                child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  data.title,
                  style: const TextStyle(
                      fontWeight: FontWeight.w600,
                      overflow: TextOverflow.ellipsis),
                ),
                Text(
                  data.subTitle,
                  overflow: TextOverflow.ellipsis,
                ),
                Wrap(
                  children: data.tags.map((e) => (TagsWidget(e))).toList(),
                ),
                Text(
                  data.price.toString() + '元/月',
                  style: const TextStyle(
                      fontWeight: FontWeight.w600, color: Colors.red),
                )
              ],
            ))
          ],
        ),
      ),
    );
  }
}
